<?php

$allpath=explode('/', $_SERVER["REQUEST_URI"]);
array_pop($allpath);
array_pop($allpath);
array_pop($allpath);
$path=implode('/',$allpath);

$http='http://';
if ($_SERVER["HTTPS"]) {
	$http='https://';
}

$origin = $http.$_SERVER["HTTP_HOST"].$path;

if (isset($_SERVER["HTTP_REFERER"])) {
	if (strpos($_SERVER["HTTP_REFERER"], $origin) == 0) {
		
		if (isset($_GET["url"])) {
			$url = $_GET["url"];
			header( "Location: {$url}" );
			exit();
		}
	}
}

// DEFAULT
//$url = $_GET["url"];
//header( "Location: {$url}" );

?>
